<template>
	<div class="publicpageview">
		<div class="topInput" v-if="type==''">
      <el-button class="buttons" type="primary" size="mini" @click="handleAddUser">统计</el-button>
			<el-form :rules='rules' :inline="true" :model="listQuery" size="mini" ref="addForm" label-width="170px">
				<div>
					<el-form-item label="区：" prop="districtName" label-width="140px">
						<el-input disabled v-model="listQuery.districtName"></el-input>
					</el-form-item>
					<el-form-item label="房管站：" prop="houseAdminName" label-width="140px">
						<el-input disabled v-model="listQuery.houseAdminName"></el-input>
					</el-form-item>
					<el-form-item label="管理形式：" prop="manageWay" label-width="140px">
						<el-select clearable v-model="listQuery.manageWay" placeholder="全部">
							<el-option label="正常" value="正常"></el-option>
							<el-option label="新纳入" value="新纳入"></el-option>
							<el-option label="托管房屋" value="托管房屋"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="产别：" prop="ownWay" label-width="140px">
						<el-select v-model="listQuery.ownWay" :disabled='listQuery.ownWay=="直管公产"'>
							<div v-for="(item,index) in chanbieList" :key="index">
								<el-option :label="item.detail" :value="item.detail" :key="index"></el-option>
							</div>
						</el-select>
					</el-form-item>
					<el-form-item label="开始时间：" prop="startDateTime" label-width="140px">
						<el-date-picker style="width: 130px;" v-model="listQuery.startDateTime" type="date" placeholder="年/月/日">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="结束时间：" prop="endDateTime" label-width="140px">
						<el-date-picker style="width: 130px;" v-model="listQuery.endDateTime" type="date" placeholder="年/月/日">
						</el-date-picker>
					</el-form-item>
					<el-form-item label="统计时间年：" prop="timeStart" label-width="140px">
							<el-input v-model="listQuery.timeStart"></el-input>
					</el-form-item>
					<el-form-item label="统计时间月：" prop="timeEnd" label-width="140px">
							<el-input v-model="listQuery.timeEnd"></el-input>
					</el-form-item> 
					<div class="radios">
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="1">直管公有住宅房屋掌管统计月报</el-radio>
						</div>
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="2">直管公有非住宅房屋掌管统计月报 </el-radio>
						</div>
					</div>
					<div class="radios">
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="3">直管公有住宅房产估价变动汇总月报</el-radio>
						</div>
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="4">直管公有非住宅房产估价变动汇总月报</el-radio>
						</div>
					</div>
					<div class="radios">
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="5">直管公有房屋建筑形式及使用性质分类统计月报</el-radio>
						</div>
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="6">直管公有非住宅房屋产权结构及健康情况统计月报</el-radio>
						</div>
					</div>
					<div class="radios">
						<div class="radioList">
							<el-radio v-model="listQuery.check0" label="7">直管公有住宅房屋产权结构及健康情况统计月报</el-radio>
						</div>
					</div>
				</div>
			</el-form>
		</div>
		
		<cybblist1 v-if="type==1" :blockobj="objData" @fanhui='fanhui'></cybblist1>
		<cybblist2 v-if="type==2" :blockobj="objData" @fanhui='fanhui'></cybblist2>
		<cybblist3 v-if="type==3" :blockobj="objData" @fanhui='fanhui'></cybblist3>
		<cybblist4 v-if="type==4" :blockobj="objData" @fanhui='fanhui'></cybblist4>
		<cybblist5 v-if="type==5" :blockobj="objData" @fanhui='fanhui'></cybblist5>
		<cybblist6 v-if="type==6" :blockobj="objData" @fanhui='fanhui'></cybblist6>
		<cybblist7 v-if="type==7" :blockobj="objData" @fanhui='fanhui'></cybblist7>
	</div>
</template>

<script>
	import cybblist1 from './feicomponents/cybblist1.vue'
	import cybblist3 from './feicomponents/cybblist3.vue'
	import cybblist2 from './feicomponents/cybblist2.vue'
	import cybblist4 from './feicomponents/cybblist4.vue'
	import cybblist5 from './feicomponents/cybblist5.vue'
	import cybblist6 from './feicomponents/cybblist6.vue'
	import cybblist7 from './feicomponents/cybblist7.vue'
	import dayjs from 'dayjs'
	import * as XLSX from 'xlsx'
	import {
		blockGroupList,
		blockList,
		blockDetail,
		notHouse,
		industryReportOne,
		industryReportTwo,
		industryReportThree,
		industryReportFour,
		industryReportFive,
		industryReportSix,
		industryReportSeven
	} from '@/api/industry'
	export default {
		name: 'AccommodationManagementChanquanzhengjian',
		components:{
			cybblist1,
			cybblist2,
			cybblist3,
			cybblist4,
			cybblist5,
			cybblist7,
			cybblist6
		},
		data() {
			return {
				listQuery: {
					check0: '',
					manageWay: '',
					districtName:'',
					houseAdminName:'',
					aid:'',
					time:'',
					timeStart:"",
					timeEnd:"",
				},
				type:'',
				objData:{},
				rules: {
					timeStart: [
						{
							required: true,
							message: '请输入年',
							trigger: 'blur'
						}
					],
					timeEnd: [
						{
							required: true,
							message: '请输入月',
							trigger: 'blur'
						}
					],
					// check1: [
					// 	{
					// 		required: true,
					// 		message: '请选择管片',
					// 		trigger: 'blur'
					// 	}
					// ],
					// check2: [
					// 	{
					// 		required: true,
					// 		message: '请选择所号',
					// 		trigger: 'blur'
					// 	}
					// ],
					// ownWay: [
					// 	{
					// 		required: true,
					// 		message: '请选择产别',
					// 		trigger: 'blur'
					// 	}
					// ]
				},
				guanpianList: [],
				blList: [],
				chanbieList: [],
				// 建筑形式
				jianzhuxingshiList: [],
				// 建筑形式明细
				jianzhuxingshimingxiList: [],
			}
		},

		computed: {},

		mounted() {
			this.listQuery.districtName = localStorage.getItem('userDname')
			this.listQuery.houseAdminName = localStorage.getItem('userHouseAdminName')
			this.listQuery.aid = localStorage.getItem('userHouseAdminId')
			// 遍历字典
			this.chanyeList = JSON.parse(localStorage.getItem('chanye'))
			this.chanyeList.forEach((item, index) => {
				if (item.classname == '产别') {
					item.classmidList.forEach((it, idx) => {
						if (it.classmid == '产别') {
							this.chanbieList = it.classdetailList
						}
					})
				} else if (item.classname == '建筑形式') {
					this.jianzhuxingshiList = item.classmidList
				}
			})
			this.blockGroupList()
			this.blockList()
			// this.listQuery.check8 = new Date()
		},

		methods: {
			// 管片列表
			blockGroupList() {
				let data = {
					group: '',
					groupNumber: '',
					houseAdmin: '',
					pageNum: '',
					pageSize: 99999
				}
				this.listLoading = true
				blockGroupList(data).then((res) => {
					this.guanpianList = res.data.list
					this.listLoading = false
					// this.houseAdminList()
				})
			},
			blockList() {
				let data = {
					limit: 99999,
					page: 1
				}
				blockList(data).then((res) => {
					this.blList = res.data.list
				})
			},
			// 选择建筑形式
			jianzhuChange(value) {
				this.chanyeList.forEach((item, index) => {
					if (item.classname == '建筑形式') {
						item.classmidList.forEach((it, idx) => {
							if (value == '楼房' && it.classmid == '楼房') {
								this.jianzhuxingshimingxiList = it.classdetailList
							} else if (value == '平房' && it.classmid == '平房') {
								this.jianzhuxingshimingxiList = it.classdetailList
							}
						})
					}
				})
			},
			blockChange(e) {
			//   this.blockid = e.blockid
			  this.listQuery.check2 = e.blockno
			
			  let data = {
			    BlockID: e.blockid
			  }
			  blockDetail(data).then((res) => {
			  })
			},
			handleAddUser(){
				this.$refs.addForm.validate((valid) => {
				  if (valid) {
						let data = this.listQuery
						this.listQuery.time = this.listQuery.timeStart + '-' + this.listQuery.timeEnd
						if(data.check0==1){
							industryReportOne(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}else if(data.check0==2){
							industryReportTwo(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}else if(data.check0==3){
							industryReportThree(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}else if(data.check0==4){
							industryReportFour(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}else if(data.check0==5){
							industryReportFive(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}else if(data.check0==6){
							industryReportSix(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}else if(data.check0==7){
							industryReportSeven(data).then(res=>{
								this.type = data.check0
								this.objData = res.data
							})
						}
						
						
				  } else {
				    return false
				  }
				})
				
			},
			fanhui(){
				this.type = ''
			}
		}
	}
</script>
<style scoped>
	.saveContent {
		width: 100%;
		display: flex;
		justify-content: end;
		margin-top: 20px;
		padding-bottom: 20px;
	}

	.title {
		color: #008c93;
		text-align: center;
		margin-bottom: 20px;
		font-weight: bold;
	}

	.cfguanpian {
		padding-bottom: 20px;
		color: #008c93;
		margin-bottom: 20px;
		font-weight: bold;
	}

	.title2 {
		color: #008c93;
		margin-bottom: 20px;
		font-weight: bold;
	}

	.tianjiaButton {
		border: 2px solid #008c93;
		background-color: #fff;
		color: #008c93;
	}

	/deep/.el-input__inner {
		width: 130px;
	}

	/deep/.publicpaginationview .el-input__inner {
		width: 100px;
	}

	/deep/.publicpaginationview .is-in-pagination .el-input__inner {
		width: 50px;
	}

	.list {
		display: flex;
	}

	.topInput {
		width: 70%;
		height: 650px;
		margin: 0 auto;
		background-color: #fff;
		padding-top: 20px;
	}

	.radios {
		display: flex;
	}

	.radioList {
		width: 800px;
		margin-top: 30px;
		margin-left: 100px;
	}
	.buttons{
		margin:20px 0 20px 90%;
		display: block;
	}
</style>